<template>
   <el-dialog
  title="编辑"
  :visible.sync="dialogVisible"
  width="40%"
  :before-close="handleClose">
  <!--  -->
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  <el-form-item label="用户ID" prop="id">
    <el-input v-model="ruleForm.id"></el-input>
  </el-form-item>
  
   <el-form-item label="微信昵称" prop="name">
    <el-input v-model.number="ruleForm.name"></el-input>
  </el-form-item>
   <el-form-item label="会员手机" prop="cell">
    <el-input v-model.number="ruleForm.cell"></el-input>
  </el-form-item>
   <el-form-item label="消费金额" prop="date">
    <el-input v-model.number="ruleForm.date"></el-input>
  </el-form-item>
   <el-form-item label="订单数量" prop="dates">
    <el-input v-model.number="ruleForm.dates"></el-input>
  </el-form-item>
   <el-form-item label="会员等级" prop="income">
    <el-input v-model.number="ruleForm.income"></el-input>
  </el-form-item>
  <el-form-item label="消费时间" prop="pay">
    <el-input v-model.number="ruleForm.pay"></el-input>
  </el-form-item>
  
</el-form>
<!--  -->
  <span slot="footer" class="dialog-footer">
    <el-button @click="$parent.isShow=false">取 消</el-button>
    <el-button type="primary" @click="submitForm('ruleForm')">确 定</el-button>
  </span>
</el-dialog>
</template>

<script>
import {updatefn} from '../../../api/Student'
export default {
    props:['row',],
    data(){
        
        return{
            // options:area,
            dialogVisible: true,
           ruleForm: {
            id:"",
            name: "",
            cell: "",
            date: "",
            dates:"", 
            income:"",
            pay:"",
            },
            rules: {
            id: [
            { required: true, message: '用户ID', trigger: 'blur' }
          ],
          name: [
            { required: true, message: '微信昵称', trigger: 'blur' },
            { min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' }
          ],
          cell: [
            { required: true, message: '会员手机', trigger: 'blur' }
          ],
          date: [
            { required: true, message: '消费金额', trigger: 'blur' }
          ],
          dates: [
            {  required: true, message: '订单数量', trigger: 'blur' }
          ],
          income: [
            {  required: true, message: '会员等级', trigger: 'blur' }
          ],
          pay: [
            {  required: true, message: '上次消费时间', trigger: 'blur' }
          ],
         
        }
        }
        
    },
    mounted(){
        this.ruleForm={...this.row}
    },
    
    methods:{
    submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
              updatefn(this.ruleForm).then(res=>{
                  if(res.code==200){
                      this.$parent.getStuData()
                      this.$parent.isShow=false
                  }
              })
          } else {
          
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }, 
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
            this.$parent.isShow=false
          })
          .catch(_ => {});
      },
    
    }
}
</script>

<style>

</style>